### Eclipse Workspace Patch 1.0 #P petals-bc-mail Index: src/main/java/org/ow2/petals/bc/mail/listeners/SessionDescriptor.java =================================================================== --- src/main/java/org/ow2/petals/bc/mail/listeners/SessionDescriptor.java (revision 15640) +++ src/main/java/org/ow2/petals/bc/mail/listeners/SessionDescriptor.java (working copy) @@ -100,6 +100,11 @@ */ private String body; + /** + * Body content type + */ + private String contentType; + private String sendMode; public String getSendMode() { @@ -114,7 +119,11 @@ return this.body; } - public String getFolder() { + public String getContentType() { + return contentType; + } + + public String getFolder() { return this.folder; } @@ -166,6 +175,10 @@ this.body = body; } + public void setContentType(String contentType) { + this.contentType = contentType; + } + public void setDelete(boolean delete) { this.delete = delete; } Index: src/main/java/org/ow2/petals/bc/mail/listeners/MimeMessageManager.java =================================================================== --- src/main/java/org/ow2/petals/bc/mail/listeners/MimeMessageManager.java (revision 15640) +++ src/main/java/org/ow2/petals/bc/mail/listeners/MimeMessageManager.java (working copy) @@ -40,6 +40,7 @@ import javax.mail.internet.MimeMultipart; import org.ow2.petals.bc.mail.Constants; +import org.ow2.petals.bc.mail.listeners.SessionDescriptor; import org.ow2.petals.component.framework.bc.AbstractBindingComponent; import org.ow2.petals.component.framework.util.UtilFactory; @@ -99,7 +100,7 @@ final Multipart multipart = new MimeMultipart(); if (!sendMode.equalsIgnoreCase(Constants.SEND_MODE_ATTACHMENTSONLY)) { // Set MimeMessage body - this.setMimeMessageBody(multipart, in); + this.setMimeMessageBody(multipart, in, descriptor.getContentType()); } if (!sendMode.equalsIgnoreCase(Constants.SEND_MODE_CONTENTONLY)) { // Set MimeMessage attachements @@ -194,13 +195,13 @@ * @throws JBIException * if the {@link Multipart} body setting failed */ - protected void setMimeMessageBody(Multipart multipart, NormalizedMessage in) + protected void setMimeMessageBody(Multipart multipart, NormalizedMessage in, String contentType) throws JBIException { String content = null; try { if (in.getContent() != null) { content = UtilFactory.getSourceUtil().createString(in.getContent()); - this.setMimeMessageBody(multipart, content); + this.setMimeMessageBody(multipart, content, contentType); } } catch (final Exception e) { throw new JBIException(e.getMessage()); @@ -217,11 +218,11 @@ * the content * @throws MessagingException */ - protected void setMimeMessageBody(Multipart multipart, String content) + protected void setMimeMessageBody(Multipart multipart, String content, String contentType) throws MessagingException { this.log.finest("set the email body"); final MimeBodyPart messageBodyPart = new MimeBodyPart(); - messageBodyPart.setContent(content, "text/plain"); + messageBodyPart.setContent(content, contentType); multipart.addBodyPart(messageBodyPart); } } Index: src/main/java/org/ow2/petals/bc/mail/Constants.java =================================================================== --- src/main/java/org/ow2/petals/bc/mail/Constants.java (revision 15640) +++ src/main/java/org/ow2/petals/bc/mail/Constants.java (working copy) @@ -28,6 +28,8 @@ public interface Constants { public static final String BODY_PATHELEMENT = "body"; + + public static final String CONTENTTYPE_PATHELEMENT = "content-type"; // If true in CONSUMES mode, assume default mail content is XML public static final String IS_XML_CONTENT = "isxmlcontent"; Index: src/main/java/org/ow2/petals/bc/mail/service/SendMailGenericService.java =================================================================== --- src/main/java/org/ow2/petals/bc/mail/service/SendMailGenericService.java (revision 15640) +++ src/main/java/org/ow2/petals/bc/mail/service/SendMailGenericService.java (working copy) @@ -112,7 +112,7 @@ // with the 'body' element of the jbi message final Multipart multipart = (Multipart) mimeMessage.getContent(); final BodyPart messageBodyPart = multipart.getBodyPart(0); - messageBodyPart.setContent(sessionDescriptor.getBody(), "text/plain"); + messageBodyPart.setContent(sessionDescriptor.getBody(), sessionDescriptor.getContentType()); // Send this mail if (this.logger.isLoggable(Level.FINEST)) { Index: src/main/java/org/ow2/petals/bc/mail/listeners/SessionDescriptorBuilder.java =================================================================== --- src/main/java/org/ow2/petals/bc/mail/listeners/SessionDescriptorBuilder.java (revision 15640) +++ src/main/java/org/ow2/petals/bc/mail/listeners/SessionDescriptorBuilder.java (working copy) @@ -267,6 +267,16 @@ } else { throw new MissingElementException(Constants.BODY_PATHELEMENT); } + + final Node contentTypeNode = XMLUtil.findChild(rootNode, Constants.CONTENTTYPE_PATHELEMENT, null, false); + String contentType = null; + if (contentTypeNode != null) { + contentType = contentTypeNode.getTextContent(); + } else { + contentType = "text/plain"; + } + sessionDescriptor.setContentType(contentType); + this.checkProperties(sessionDescriptor); return sessionDescriptor; }